package com.ijunfu.common.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 *
 * @Title  : 
 * @Author : ijunfu <ijunfu@163.com>
 * @Date   : 2024/2/6 22:39
 * @Version: 1.0
 * @Motto  : 简洁的代码是智慧的结晶 卓越的编码是对复杂性的优雅征服
 *
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class R<T> {

    private Integer code;

    private String message;

    private T data;

    public static R ok() {
        return new R(ResultType.SUCCESS.getCode(), null, null);
    }

    public static R ok(String message) {
        return new R(ResultType.SUCCESS.getCode(), message, null);
    }

    public static <T> R ok(T t) {
        return new R(ResultType.SUCCESS.getCode(), null, t);
    }

    public static R fail() {
        return new R(ResultType.FAIL.getCode(), null, null);
    }

    public static R fail(String message) {
        return new R(ResultType.FAIL.getCode(), message, null);
    }

    public static <T> R fail(T t) {
        return new R(ResultType.FAIL.getCode(), null, t);
    }
}
